function formatGitLogs(logsString) {
  let logs = JSON.parse(logsString)
  
  logs = logs.map(log => formatGitLog(log))
  
  return logs
}

function formatGitLog(log) {
  log.date = log.date.substr(0, 19)
  log.author = log.author.substr(0, 3)
  return log
}

function formatGitLogsWithInquirer(logsString) {
  let logs = formatGitLogs(logsString)
  let logMap = {}
  
  logs.map(log => {
    let key = `commit: ${log.commit} - author: ${log.author} - date: ${log.date} - message: ${log.message}`
    logMap[key] = log
    return key
  })
  
  return {
    logs,
    logMap
  }
}

exports.formatGitLogs = formatGitLogs
exports.formatGitLogsWithInquirer = formatGitLogsWithInquirer

module.exports = {
  formatGitLogs,
  formatGitLogsWithInquirer
}